﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Libs.Content;

public partial class Controls_Home_HotNews : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack) return;

        NewsWeb _NewsWeb = new NewsWeb();
        NewsCategories _Cate = new NewsCategories() { CateID = 16 };
        List<NewsWeb> list;

        list = _NewsWeb.GetListOriginalCate(_Cate.CateID, 1);
        _Cate = _Cate.Get();

        _NewsWeb = list[0];

        // Bài top trang chủ
        imgNewsTop.Src = AppUtils.ImageUrl(_NewsWeb.ImageUrl, "379", "259");
        hlNewsTop.HRef = hlNewsImgTop.HRef = Constant.HOME_PATH + _NewsWeb.Url;
        hlNewsTop.InnerText = _NewsWeb.Title;
        ltrLead.Text = _NewsWeb.SubLead;

        // 3 tiếp theo
        list = _NewsWeb.GetListOriginalCate(_Cate.CateID, _NewsWeb.NewsID, 3);
        for (int i = 0; i < list.Count; i++)
        {
            _NewsWeb = list[i];
            _NewsWeb.ImageUrl = AppUtils.ImageUrl(_NewsWeb.ImageUrl, "113", "68");
            list[i] = _NewsWeb;
        }
        rptList1.DataSource = list;
        rptList1.DataBind();

        // 5 bài tiếp theo
        rptList2.DataSource = _NewsWeb.GetListOriginalCate(_Cate.CateID, _NewsWeb.NewsID, 5);
        rptList2.DataBind();
    }
}